package problemLCR179;

//LCR179.查找总价格为目标值的两个商品
//https://leetcode.cn/problems/he-wei-sde-liang-ge-shu-zi-lcof/

class Solution {
    public int[] twoSum(int[] price, int target) {
        int n = price.length;
        int l = 0, r = n-1;
        while(l < r) {
            if(price[l] + price[r] == target) {
                return new int[]{price[l], price[r]};
            }else if(price[l] + price[r] < target) {
                l++;
            }else {
                r--;
            }
        }
        return new int[2];
    }
}